### HOW ELITE MESSAGING AND SOCIAL EXCLUSION SHAPE ASIAN AMERICAN PARTISAN ATTITUDES DURING TIMES OF PANDEMIC ###

#PERSPECTIVES ON POLITICS##

### AUTHORS: CHAN, KIM, and LEUNG; contact nkchan@Uci.edu ###

#load packages 
library(tidyverse)
library(ggpubr)
library(ggeffects)
library(pacman)
library(sensemakr)
library(sjPlot)
library(haven)
library(questionr)
library(stargazer)
library(Matching)
library(rbounds)
library(mice)
library(openxlsx)
library(rio)
library(readxl)
library(MatchIt)
library(Zelig)
library(ZeligChoice)
library(ggplot2)
library(scales)
library(here)
library(ggthemes)
library(readxl)
theme_set(theme_pubr())

#load in data
scape <- read.csv("C:/Users/natha/Dropbox/POP_Asian Americans_Data.csv")

### code variables of interest ####

#race
scape$race <- NA
scape$race <- as.character(scape$race)
scape$race[scape$race_ethnicity==1] <- "White"
scape$race[scape$race_ethnicity==2] <- "Black"
scape$race[scape$race_ethnicity==3] <- "Native American"
scape$race[scape$race_ethnicity==4] <- "Asian Indian"
scape$race[scape$race_ethnicity==5] <- "Asian Chinese"
scape$race[scape$race_ethnicity==6] <- "Asian Filipino"
scape$race[scape$race_ethnicity==7] <- "Asian Japanese"
scape$race[scape$race_ethnicity==8] <- "Asian Korean"
scape$race[scape$race_ethnicity==9] <- "Asian Vietnamese"
scape$race[scape$race_ethnicity==10] <- "Asian Other"
scape$race[scape$race_ethnicity==11] <- "Asian Pacific Islander (Hawaiian)"
scape$race[scape$race_ethnicity==12] <- "Asian Pacific Islander (Guamanian)"
scape$race[scape$race_ethnicity==13] <- "Asian Pacific Islander (Samoan)"
scape$race[scape$race_ethnicity==14] <- "Asian Pacific Islander (Other)"
scape$race[scape$race_ethnicity==15] <-  "Other"
table(scape$race)

#asian
scape$asian <- NA
scape$asian <- as.numeric(scape$asian)
scape$asian[scape$race_ethnicity==1] <- 0
scape$asian[scape$race_ethnicity==2] <- 0
scape$asian[scape$race_ethnicity==3] <- 0
scape$asian[scape$race_ethnicity==4] <- 1
scape$asian[scape$race_ethnicity==5] <- 1
scape$asian[scape$race_ethnicity==6] <- 1
scape$asian[scape$race_ethnicity==7] <- 1
scape$asian[scape$race_ethnicity==8] <- 1
scape$asian[scape$race_ethnicity==9] <- 1
scape$asian[scape$race_ethnicity==10] <- 1
scape$asian[scape$race_ethnicity==11] <- 1
scape$asian[scape$race_ethnicity==12] <- 1
scape$asian[scape$race_ethnicity==13] <- 1
scape$asian[scape$race_ethnicity==14] <- 1
scape$asian[scape$race_ethnicity==15] <- 0
table(scape$asian)

#chinese: 1=chinese; 0.5=asian but not chinese; 0=not asian
scape$chinese <- NA
scape$chinese <- as.character(scape$chinese)
scape$chinese[scape$race_ethnicity==1] <- 0
scape$chinese[scape$race_ethnicity==2] <- 0
scape$chinese[scape$race_ethnicity==3] <- 0
scape$chinese[scape$race_ethnicity==4] <- 0.5
scape$chinese[scape$race_ethnicity==5] <- 1
scape$chinese[scape$race_ethnicity==6] <- 0.5
scape$chinese[scape$race_ethnicity==7] <- 0.5
scape$chinese[scape$race_ethnicity==8] <- 0.5
scape$chinese[scape$race_ethnicity==9] <- 0.5
scape$chinese[scape$race_ethnicity==10] <- 0.5
scape$chinese[scape$race_ethnicity==11] <- 0.5
scape$chinese[scape$race_ethnicity==12] <- 0.5
scape$chinese[scape$race_ethnicity==13] <- 0.5
scape$chinese[scape$race_ethnicity==14] <- 0.5
scape$chinese[scape$race_ethnicity==15] <-  0
table(scape$chinese)

#white
scape$white <- NA
scape$white <- as.numeric(scape$white)
scape$white[scape$race_ethnicity==1] <- 1
scape$white[scape$race_ethnicity==2] <- 0
scape$white[scape$race_ethnicity==3] <- 0
scape$white[scape$race_ethnicity==4] <- 0
scape$white[scape$race_ethnicity==5] <- 0
scape$white[scape$race_ethnicity==6] <- 0
scape$white[scape$race_ethnicity==7] <- 0
scape$white[scape$race_ethnicity==8] <- 0
scape$white[scape$race_ethnicity==9] <- 0
scape$white[scape$race_ethnicity==10] <- 0
scape$white[scape$race_ethnicity==11] <- 0
scape$white[scape$race_ethnicity==12] <- 0
scape$white[scape$race_ethnicity==13] <- 0
scape$white[scape$race_ethnicity==14] <- 0
scape$white[scape$race_ethnicity==15] <- 0
table(scape$white)

#black
scape$black <- NA
scape$black <- as.numeric(scape$black)
scape$black[scape$race_ethnicity==1] <- 0
scape$black[scape$race_ethnicity==2] <- 1
scape$black[scape$race_ethnicity==3] <- 0
scape$black[scape$race_ethnicity==4] <- 0
scape$black[scape$race_ethnicity==5] <- 0
scape$black[scape$race_ethnicity==6] <- 0
scape$black[scape$race_ethnicity==7] <- 0
scape$black[scape$race_ethnicity==8] <- 0
scape$black[scape$race_ethnicity==9] <- 0
scape$black[scape$race_ethnicity==10] <- 0
scape$black[scape$race_ethnicity==11] <- 0
scape$black[scape$race_ethnicity==12] <- 0
scape$black[scape$race_ethnicity==13] <- 0
scape$black[scape$race_ethnicity==14] <- 0
scape$black[scape$race_ethnicity==15] <- 0
table(scape$black)

#latinx
scape$latinx <- NA
scape$latinx <- as.numeric(scape$latinx)
scape$latinx[scape$hispanic==1] <- 0
scape$latinx[scape$hispanic==2] <- 1
scape$latinx[scape$hispanic==3] <- 1
scape$latinx[scape$hispanic==4] <- 1
scape$latinx[scape$hispanic==5] <- 1
scape$latinx[scape$hispanic==6] <- 1
scape$latinx[scape$hispanic==7] <- 1
scape$latinx[scape$hispanic==8] <- 1
scape$latinx[scape$hispanic==9] <- 1
scape$latinx[scape$hispanic==10] <- 1
scape$latinx[scape$hispanic==11] <- 1
scape$latinx[scape$hispanic==12] <- 1
scape$latinx[scape$hispanic==13] <- 1
scape$latinx[scape$hispanic==14] <- 1
scape$latinx[scape$hispanic==15] <- 1
table(scape$latinx)

###Democratic Party Favorability#
table(scape$group_favorability_democrats)
scape$dem.fav <- NA
scape$dem.fav <- as.character(scape$dem.fav)
scape$dem.fav[scape$group_favorability_democrats==1] <- "1. Favorable"
scape$dem.fav[scape$group_favorability_democrats==2] <- "1. Favorable"
scape$dem.fav[scape$group_favorability_democrats==3] <- "2. Unfavorable"
scape$dem.fav[scape$group_favorability_democrats==4] <- "2. Unfavorable"
scape$dem.fav[scape$group_favorability_democrats==999] <- "3. DK"
table(scape$dem.fav)

scape$dem.fav.n <- NA
scape$dem.fav.n <- as.numeric(scape$dem.fav.n)
scape$dem.fav.n[scape$group_favorability_democrats==1] <- 1
scape$dem.fav.n[scape$group_favorability_democrats==2] <- 0.75
scape$dem.fav.n[scape$group_favorability_democrats==3] <- 0.25
scape$dem.fav.n[scape$group_favorability_democrats==4] <- 0
scape$dem.fav.n[scape$group_favorability_democrats==999] <- 0.5
table(scape$dem.fav.n)

### BIDEN FAVORABILITY ##
table(scape$cand_favorability_biden)
scape$biden.fav <- NA
scape$biden.fav <- as.character(scape$biden.fav)
scape$biden.fav[scape$cand_favorability_biden==1] <- "1. Favorable"
scape$biden.fav[scape$cand_favorability_biden==2] <- "1. Favorable"
scape$biden.fav[scape$cand_favorability_biden==3] <- "2. Unfavorable"
scape$biden.fav[scape$cand_favorability_biden==4] <- "2. Unfavorable"
scape$biden.fav[scape$cand_favorability_biden==999] <- "3. DK"
table(scape$biden.fav)

table(scape$cand_favorability_biden)
scape$biden.fav.n <- NA
scape$biden.fav.n <- as.numeric(scape$biden.fav.n)
scape$biden.fav.n[scape$cand_favorability_biden==1] <- 1
scape$biden.fav.n[scape$cand_favorability_biden==2] <- 0.75
scape$biden.fav.n[scape$cand_favorability_biden==3] <- 0.25
scape$biden.fav.n[scape$cand_favorability_biden==4] <- 0
scape$biden.fav.n[scape$cand_favorability_biden==999] <- 0.5
table(scape$biden.fav.n)

### PARTY IDENTIFICATION ###
table(scape$pid3)
scape$party <- NA
scape$party <- as.character(scape$party)
scape$party[scape$pid3==1] <- "1. Democrat" 
scape$party[scape$pid3==2] <- "2. Republican"
scape$party[scape$pid3==3] <- "3. Independent"
scape$party[scape$pid3==4] <- "4. Something else"
table(scape$party)

scape$dem <- NA
scape$dem <- as.numeric(scape$dem)
scape$dem[scape$pid3==1] <- 1
scape$dem[scape$pid3==2] <- 0
scape$dem[scape$pid3==3] <- 0
scape$dem[scape$pid3==4] <- 0
table(scape$dem)

#propdem index
scape$prodem <- NA
scape$prodem <- as.numeric(scape$prodem)
scape$prodem <- as.numeric((scape$dem)+(scape$dem.fav.n)+(scape$biden.fav.n))/3
table(scape$prodem)

#use for wave fixed effects
table(scape$wave)

scape$wavenumber <- NA
scape$wavenumber <- as.numeric(scape$wavenumber)
scape$wavenumber[scape$wave=="ns20190718"] <- 1
scape$wavenumber[scape$wave=="ns20190725"] <- 2
scape$wavenumber[scape$wave=="ns20190801"] <- 3
scape$wavenumber[scape$wave=="ns20190808"] <- 4
scape$wavenumber[scape$wave=="ns20190815"] <- 5
scape$wavenumber[scape$wave=="ns20190822"] <- 6
scape$wavenumber[scape$wave=="ns20190829"] <- 7
scape$wavenumber[scape$wave=="ns20190905"] <- 8
scape$wavenumber[scape$wave=="ns20190912"] <- 9
scape$wavenumber[scape$wave=="ns20190919"] <- 10
#### OCTOBER #####
scape$wavenumber[scape$wave=="ns20190926"] <- 11
scape$wavenumber[scape$wave=="ns20191003"] <- 12
scape$wavenumber[scape$wave=="ns20191010"] <- 13
scape$wavenumber[scape$wave=="ns20191017"] <- 14
scape$wavenumber[scape$wave=="ns20191024"] <- 15
###NOVEMBER#####
scape$wavenumber[scape$wave=="ns20191031"] <- 16
scape$wavenumber[scape$wave=="ns20191107"] <- 17
scape$wavenumber[scape$wave=="ns20191114"] <- 18
scape$wavenumber[scape$wave=="ns20191121"] <- 19
###DECEMBER
scape$wavenumber[scape$wave=="ns20191128"] <- 20
scape$wavenumber[scape$wave=="ns20191205"] <- 21
scape$wavenumber[scape$wave=="ns20191212"] <- 22
scape$wavenumber[scape$wave=="ns20191219"] <- 23
scape$wavenumber[scape$wave=="ns20191226"] <- 24
#JANUARY first reports of covid on December 31, 2019
scape$wavenumber[scape$wave=="ns20200102"] <- 25
scape$wavenumber[scape$wave=="ns20200109"] <- 26
scape$wavenumber[scape$wave=="ns20200116"] <- 27
##first confirmed case of covid on January 21, 2020
scape$wavenumber[scape$wave=="ns20200123"] <- 28
#### FEBRUARY
scape$wavenumber[scape$wave=="ns20200130"] <- 29
scape$wavenumber[scape$wave=="ns20200206"] <- 30
scape$wavenumber[scape$wave=="ns20200213"] <- 31
scape$wavenumber[scape$wave=="ns20200220"] <- 32
###MARCH
##virus transmission on February 26; first death on February 29, 2020
scape$wavenumber[scape$wave=="ns20200227"] <- 33
scape$wavenumber[scape$wave=="ns20200305"] <- 34
scape$wavenumber[scape$wave=="ns20200312"] <- 35
##March 16; Chinese Virus
scape$wavenumber[scape$wave=="ns20200319"] <- 36
###APRIL
scape$wavenumber[scape$wave=="ns20200326"] <- 37
scape$wavenumber[scape$wave=="ns20200402"] <- 38
scape$wavenumber[scape$wave=="ns20200409"] <- 39
scape$wavenumber[scape$wave=="ns20200416"] <- 40
scape$wavenumber[scape$wave=="ns20200423"] <- 41
####MAY
scape$wavenumber[scape$wave=="ns20200430"] <- 42
table(scape$wavenumber)
table(scape$wave)

### SECTIONS BASED ON CHINESE VIRUS ####
table(scape$wavenumber)
scape$sections <- NA
scape$sections <- as.character(scape$sections)
scape$sections[scape$wavenumber==1] <- "Section 0"
scape$sections[scape$wavenumber==2] <- "Section 0"
scape$sections[scape$wavenumber==3] <- "Section 0"
scape$sections[scape$wavenumber==4] <- "Section 0"
scape$sections[scape$wavenumber==5] <- "Section 0"
scape$sections[scape$wavenumber==6] <- "Section 0"
scape$sections[scape$wavenumber==7] <- "Section 0"
scape$sections[scape$wavenumber==8] <- "Section 0"
scape$sections[scape$wavenumber==9] <- "Section 0"
scape$sections[scape$wavenumber==10] <- "Section 0"
scape$sections[scape$wavenumber==11] <- "Section 1"
scape$sections[scape$wavenumber==12] <- "Section 1"
scape$sections[scape$wavenumber==13] <-  "Section 1" 
scape$sections[scape$wavenumber==14] <-   "Section 1"
scape$sections[scape$wavenumber==15] <- "Section 1"  
scape$sections[scape$wavenumber==16] <- "Section 2"
scape$sections[scape$wavenumber==17] <- "Section 2"
scape$sections[scape$wavenumber==18] <- "Section 2"
scape$sections[scape$wavenumber==19] <-  "Section 2" 
scape$sections[scape$wavenumber==20] <-  "Section 3" 
scape$sections[scape$wavenumber==21] <- "Section 3"  
scape$sections[scape$wavenumber==22] <- "Section 3"  
scape$sections[scape$wavenumber==23] <-   "Section 3"
scape$sections[scape$wavenumber==24] <-  "Section 3" 
scape$sections[scape$wavenumber==25] <- "Section 4"  
scape$sections[scape$wavenumber==26] <- "Section 4"  
scape$sections[scape$wavenumber==27] <-  "Section 4" 
scape$sections[scape$wavenumber==28] <- "Section 5"  
scape$sections[scape$wavenumber==29] <-   "Section 5"
scape$sections[scape$wavenumber==30] <-  "Section 5" 
scape$sections[scape$wavenumber==31] <- "Section 5"  
scape$sections[scape$wavenumber==32] <-   "Section 5"
scape$sections[scape$wavenumber==33] <-  "Section 6" 
scape$sections[scape$wavenumber==34] <-"Section 6"   
scape$sections[scape$wavenumber==35] <- "Section 6"  
scape$sections[scape$wavenumber==36] <- "Section 7"  
scape$sections[scape$wavenumber==37] <-  "Section 7" 
scape$sections[scape$wavenumber==38] <-  "Section 7" 
scape$sections[scape$wavenumber==39] <- "Section 7"  
scape$sections[scape$wavenumber==40] <- "Section 8"  
scape$sections[scape$wavenumber==41] <- "Section 8"  
scape$sections[scape$wavenumber==42] <- "Section 8"
table(scape$sections)

scape$sections.n <- NA
scape$sections.n <- as.numeric(scape$sections.n)
scape$sections.n[scape$sections=="Section 0"] <- 0
scape$sections.n[scape$sections=="Section 1"] <- 1
scape$sections.n[scape$sections=="Section 2"] <- 2
scape$sections.n[scape$sections=="Section 3"] <- 3
scape$sections.n[scape$sections=="Section 4"] <- 4
scape$sections.n[scape$sections=="Section 5"] <- 5
scape$sections.n[scape$sections=="Section 6"] <- 6
scape$sections.n[scape$sections=="Section 7"] <- 7
scape$sections.n[scape$sections=="Section 8"] <- 8
table(scape$sections.n)

#indicator variable for pre and post china virus
scape$chinavirus <- NA
scape$chinavirus <- as.numeric(scape$chinavirus)
scape$chinavirus[scape$sections=="Section 0"] <- 0
scape$chinavirus[scape$sections=="Section 1"] <- 0
scape$chinavirus[scape$sections=="Section 2"] <- 0
scape$chinavirus[scape$sections=="Section 3"] <- 0
scape$chinavirus[scape$sections=="Section 4"] <- 0
scape$chinavirus[scape$sections=="Section 5"] <- 0
scape$chinavirus[scape$sections=="Section 6"] <- 0
scape$chinavirus[scape$sections=="Section 7"] <- 1
scape$chinavirus[scape$sections=="Section 8"] <- 1
table(scape$chinavirus)

#age 
table(scape$age)
scape$age.n <- NA
scape$age.n <- as.numeric(scape$age.n)
scape$age.n <- as.numeric(scape$age)/100
table(scape$age.n)

#gender 
table(scape$gender)
scape$female <- NA
scape$female <- as.numeric(scape$female)
scape$female[scape$gender==1] <- 1
scape$female[scape$gender==2] <- 0
table(scape$female)   

#protestant
table(scape$religion)
scape$protestant <- NA
scape$protestant <- as.numeric(scape$protestant)
scape$protestant <- ifelse(scape$religion==1,1,0)
table(scape$protestant)

#income
table(scape$household_income)
scape$income <- NA
scape$income <- as.numeric(scape$income)
scape$income[scape$household_income==1] <- 0
scape$income[scape$household_income==2] <- 0.043
scape$income[scape$household_income==3] <- 0.086
scape$income[scape$household_income==4] <- 0.13
scape$income[scape$household_income==5] <- 0.174
scape$income[scape$household_income==6] <- 0.217
scape$income[scape$household_income==7] <- 0.261
scape$income[scape$household_income==8] <- 0.304
scape$income[scape$household_income==9] <- 0.348
scape$income[scape$household_income==10] <- 0.391
scape$income[scape$household_income==11] <- 0.435
scape$income[scape$household_income==12] <- 0.478
scape$income[scape$household_income==13] <- 0.522
scape$income[scape$household_income==14] <- 0.565
scape$income[scape$household_income==15] <- 0.609
scape$income[scape$household_income==16] <- 0.652
scape$income[scape$household_income==17] <- 0.696
scape$income[scape$household_income==18] <- 0.739
scape$income[scape$household_income==19] <- 0.783
scape$income[scape$household_income==20] <- 0.826
scape$income[scape$household_income==21] <- 0.87
scape$income[scape$household_income==22] <- 0.913
scape$income[scape$household_income==23] <- 0.957
scape$income[scape$household_income==24] <- 1
table(scape$income)

scape$income.bin <- NA
scape$income.bin <- as.numeric(scape$income.bin)
scape$income.bin <- ifelse(scape$income>0.4370296,1,0)
table(scape$income.bin)

#education
table(scape$education)
scape$education.level <- NA
scape$education.level <- as.numeric(scape$education.level)
scape$education.level[scape$education==1] <- 0
scape$education.level[scape$education==2] <- 0.1
scape$education.level[scape$education==3] <- 0.2 
scape$education.level[scape$education==4] <- 0.3
scape$education.level[scape$education==5] <- 0.4
scape$education.level[scape$education==6] <- 0.5
scape$education.level[scape$education==7] <- 0.6
scape$education.level[scape$education==8] <- 0.7
scape$education.level[scape$education==9] <- 0.8
scape$education.level[scape$education==10] <- 0.9
scape$education.level[scape$education==11] <- 1
table(scape$education.level)

#ideology
table(scape$ideo5)
scape$liberal <- NA
scape$liberal <- as.numeric(scape$liberal)
scape$liberal <- ifelse(scape$ideo5==1|scape$ideo5==2,1,0)
table(scape$liberal)

#place of birth
table(scape$foreign_born)
scape$forborn <- NA
scape$forborn <- as.numeric(scape$forborn)
scape$forborn[scape$foreign_born==1] <- 0
scape$forborn[scape$foreign_born==2] <- 1
table(scape$forborn)


#### SUBSET DATA BY RACE ####
#12,907
aapi <- subset(scape, subset=(asian==1))
#200,158=white
white <- subset(scape, subset=(white==1))
#32,364=black
black <- subset(scape, subset=(black==1))
##38,549=latinx
latinx <- subset(scape, subset=(latinx==1))

#indicator for Chinese
aapi$chinese.int <- NA
aapi$chinese.int <- as.character(aapi$chinese.int)
aapi$chinese.int[aapi$race_ethnicity==1] <- 0
aapi$chinese.int[aapi$race_ethnicity==2] <- 0
aapi$chinese.int[aapi$race_ethnicity==3] <- 0
aapi$chinese.int[aapi$race_ethnicity==4] <- 0
aapi$chinese.int[aapi$race_ethnicity==5] <- 1
aapi$chinese.int[aapi$race_ethnicity==6] <- 0
aapi$chinese.int[aapi$race_ethnicity==7] <- 0
aapi$chinese.int[aapi$race_ethnicity==8] <- 0
aapi$chinese.int[aapi$race_ethnicity==9] <- 0
aapi$chinese.int[aapi$race_ethnicity==10] <- 0
aapi$chinese.int[aapi$race_ethnicity==11] <- 0
aapi$chinese.int[aapi$race_ethnicity==12] <- 0
aapi$chinese.int[aapi$race_ethnicity==13] <- 0
aapi$chinese.int[aapi$race_ethnicity==14] <- 0
aapi$chinese.int[aapi$race_ethnicity==15] <-  0
table(aapi$chinese.int)

### SUBSET BY RACE AND SECTIONS 

##AAPI BY SECTION
table(aapi$sections.n)
aapi.sect0 <- subset(aapi, subset=sections.n==0)
aapi.sect1 <- subset(aapi, subset=sections.n==1)
aapi.sect2 <- subset(aapi, subset=sections.n==2)
aapi.sect3 <- subset(aapi, subset=sections.n==3)
aapi.sect4 <- subset(aapi, subset=sections.n==4)
aapi.sect5 <- subset(aapi, subset=sections.n==5)
aapi.sect6 <- subset(aapi, subset=sections.n==6)
aapi.sect7 <- subset(aapi, subset=sections.n==7)
aapi.sect8 <- subset(aapi, subset=sections.n==8)
aapi.prechinavirus <- subset(aapi, subset=chinavirus==0)
aapi.postchinavirus <- subset(aapi, subset=(chinavirus==1))

#Latinx by section
latinx.sect0 <- subset(latinx, subset=sections.n==0)
latinx.sect1 <- subset(latinx, subset=sections.n==1)
latinx.sect2 <- subset(latinx, subset=sections.n==2)
latinx.sect3 <- subset(latinx, subset=sections.n==3)
latinx.sect4 <- subset(latinx, subset=sections.n==4)
latinx.sect5 <- subset(latinx, subset=sections.n==5)
latinx.sect6 <- subset(latinx, subset=sections.n==6)
latinx.sect7 <- subset(latinx, subset=sections.n==7)
latinx.sect8 <- subset(latinx, subset=sections.n==8)
latinx.prechinavirus <- subset(latinx, subset=chinavirus==0)
latinx.postchinavirus <- subset(latinx, subset=(chinavirus==1))

#black by section
black.sect0 <- subset(black, subset=sections.n==0)
black.sect1 <- subset(black, subset=sections.n==1)
black.sect2 <- subset(black, subset=sections.n==2)
black.sect3 <- subset(black, subset=sections.n==3)
black.sect4 <- subset(black, subset=sections.n==4)
black.sect5 <- subset(black, subset=sections.n==5)
black.sect6 <- subset(black, subset=sections.n==6)
black.sect7 <- subset(black, subset=sections.n==7)
black.sect8 <- subset(black, subset=sections.n==8)
black.prechinavirus <- subset(black, subset=chinavirus==0)
black.postchinavirus <- subset(black, subset=(chinavirus==1))

#white by section
white.sect0 <- subset(white, subset=sections.n==0)
white.sect1 <- subset(white, subset=sections.n==1)
white.sect2 <- subset(white, subset=sections.n==2)
white.sect3 <- subset(white, subset=sections.n==3)
white.sect4 <- subset(white, subset=sections.n==4)
white.sect5 <- subset(white, subset=sections.n==5)
white.sect6 <- subset(white, subset=sections.n==6)
white.sect7 <- subset(white, subset=sections.n==7)
white.sect8 <- subset(white, subset=sections.n==8)
white.prechinavirus <- subset(white, subset=chinavirus==0)
white.postchinavirus <- subset(white, subset=(chinavirus==1))


### BEGIN ANALYSES: FIGURE 4 ###
### TIMESERIES DATA ANALYSIS ###

###### #LOOOK AT ASIAN AMERICANS DEM FAVORABILITY OVER TIME; WEIGHTS 
prop.table(wtd.table(aapi.sect0$dem.fav, weights=aapi.sect0$weight))
prop.table(wtd.table(aapi.sect1$dem.fav, weights=aapi.sect1$weight))
prop.table(wtd.table(aapi.sect2$dem.fav, weights=aapi.sect2$weight))
prop.table(wtd.table(aapi.sect3$dem.fav, weights=aapi.sect3$weight))
prop.table(wtd.table(aapi.sect4$dem.fav, weights=aapi.sect4$weight))
prop.table(wtd.table(aapi.sect5$dem.fav, weights=aapi.sect5$weight))
prop.table(wtd.table(aapi.sect6$dem.fav, weights=aapi.sect6$weight))
prop.table(wtd.table(aapi.sect7$dem.fav, weights=aapi.sect7$weight))
prop.table(wtd.table(aapi.sect8$dem.fav, weights=aapi.sect8$weight))
prop.table(wtd.table(aapi.prechinavirus$dem.fav, weights=aapi.prechinavirus$weight))
prop.table(wtd.table(aapi.postchinavirus$dem.fav, weight=aapi.postchinavirus$weight))

#look at white dem favorability over time, weights
prop.table(wtd.table(white.sect0$dem.fav, weights=white.sect0$weight))
prop.table(wtd.table(white.sect1$dem.fav, weights=white.sect1$weight))
prop.table(wtd.table(white.sect2$dem.fav, weights=white.sect2$weight))
prop.table(wtd.table(white.sect3$dem.fav, weights=white.sect3$weight))
prop.table(wtd.table(white.sect4$dem.fav, weights=white.sect4$weight))
prop.table(wtd.table(white.sect5$dem.fav, weights=white.sect5$weight))
prop.table(wtd.table(white.sect6$dem.fav, weights=white.sect6$weight))
prop.table(wtd.table(white.sect7$dem.fav, weights=white.sect7$weight))
prop.table(wtd.table(white.sect8$dem.fav, weights=white.sect8$weight))
prop.table(wtd.table(white.prechinavirus$dem.fav, weights=white.prechinavirus$weight))
prop.table(wtd.table(white.postchinavirus$dem.fav, weights=white.postchinavirus$weight))

#look at black dem favorability over time; weights
prop.table(wtd.table(black.sect0$dem.fav, weights=black.sect0$weight))
prop.table(wtd.table(black.sect1$dem.fav, weights=black.sect1$weight))
prop.table(wtd.table(black.sect2$dem.fav, weights=black.sect2$weight))
prop.table(wtd.table(black.sect3$dem.fav, weights=black.sect3$weight))
prop.table(wtd.table(black.sect4$dem.fav, weights=black.sect4$weight))
prop.table(wtd.table(black.sect5$dem.fav, weights=black.sect5$weight))
prop.table(wtd.table(black.sect6$dem.fav, weights=black.sect6$weight))
prop.table(wtd.table(black.sect7$dem.fav, weights=black.sect7$weight))
prop.table(wtd.table(black.sect8$dem.fav, weights=black.sect8$weight))
prop.table(wtd.table(black.prechinavirus$dem.fav, weights=black.prechinavirus$weight))
prop.table(wtd.table(black.postchinavirus$dem.fav, weights=black.postchinavirus$weight))

#look at latinx dem favorability over time; weights
prop.table(wtd.table(latinx.sect0$dem.fav, weights=latinx.sect0$weight))
prop.table(wtd.table(latinx.sect1$dem.fav, weights=latinx.sect1$weight))
prop.table(wtd.table(latinx.sect2$dem.fav, weights=latinx.sect2$weight))
prop.table(wtd.table(latinx.sect3$dem.fav, weights=latinx.sect3$weight))
prop.table(wtd.table(latinx.sect4$dem.fav, weights=latinx.sect4$weight))
prop.table(wtd.table(latinx.sect5$dem.fav, weights=latinx.sect5$weight))
prop.table(wtd.table(latinx.sect6$dem.fav, weights=latinx.sect6$weight))
prop.table(wtd.table(latinx.sect7$dem.fav, weights=latinx.sect7$weight))
prop.table(wtd.table(latinx.sect8$dem.fav, weights=latinx.sect8$weight))
prop.table(wtd.table(latinx.prechinavirus$dem.fav, weights=latinx.prechinavirus$weight))
prop.table(wtd.table(latinx.postchinavirus$dem.fav, weights=latinx.postchinavirus$weight))

###### #LOOOK AT ASIAN AMERICANS BIDEN FAVORABILITY OVER TIME; WEIGHTS 
prop.table(wtd.table(aapi.sect0$biden.fav, weights=aapi.sect0$weight))
prop.table(wtd.table(aapi.sect1$biden.fav, weights=aapi.sect1$weight))
prop.table(wtd.table(aapi.sect2$biden.fav, weights=aapi.sect2$weight))
prop.table(wtd.table(aapi.sect3$biden.fav, weights=aapi.sect3$weight))
prop.table(wtd.table(aapi.sect4$biden.fav, weights=aapi.sect4$weight))
prop.table(wtd.table(aapi.sect5$biden.fav, weights=aapi.sect5$weight))
prop.table(wtd.table(aapi.sect6$biden.fav, weights=aapi.sect6$weight))
prop.table(wtd.table(aapi.sect7$biden.fav, weights=aapi.sect7$weight))
prop.table(wtd.table(aapi.sect8$biden.fav, weights=aapi.sect8$weight))
prop.table(wtd.table(aapi.prechinavirus$biden.fav, weights=aapi.prechinavirus$weight))
prop.table(wtd.table(aapi.postchinavirus$biden.fav, weight=aapi.postchinavirus$weight))

#look at white biden favorability over time, weights
prop.table(wtd.table(white.sect0$biden.fav, weights=white.sect0$weight))
prop.table(wtd.table(white.sect1$biden.fav, weights=white.sect1$weight))
prop.table(wtd.table(white.sect2$biden.fav, weights=white.sect2$weight))
prop.table(wtd.table(white.sect3$biden.fav, weights=white.sect3$weight))
prop.table(wtd.table(white.sect4$biden.fav, weights=white.sect4$weight))
prop.table(wtd.table(white.sect5$biden.fav, weights=white.sect5$weight))
prop.table(wtd.table(white.sect6$biden.fav, weights=white.sect6$weight))
prop.table(wtd.table(white.sect7$biden.fav, weights=white.sect7$weight))
prop.table(wtd.table(white.sect8$biden.fav, weights=white.sect8$weight))
prop.table(wtd.table(white.prechinavirus$biden.fav, weights=white.prechinavirus$weight))
prop.table(wtd.table(white.postchinavirus$biden.fav, weights=white.postchinavirus$weight))

#look at black biden favorability over time; weights
prop.table(wtd.table(black.sect0$biden.fav, weights=black.sect0$weight))
prop.table(wtd.table(black.sect1$biden.fav, weights=black.sect1$weight))
prop.table(wtd.table(black.sect2$biden.fav, weights=black.sect2$weight))
prop.table(wtd.table(black.sect3$biden.fav, weights=black.sect3$weight))
prop.table(wtd.table(black.sect4$biden.fav, weights=black.sect4$weight))
prop.table(wtd.table(black.sect5$biden.fav, weights=black.sect5$weight))
prop.table(wtd.table(black.sect6$biden.fav, weights=black.sect6$weight))
prop.table(wtd.table(black.sect7$biden.fav, weights=black.sect7$weight))
prop.table(wtd.table(black.sect8$biden.fav, weights=black.sect8$weight))
prop.table(wtd.table(black.prechinavirus$biden.fav, weights=black.prechinavirus$weight))
prop.table(wtd.table(black.postchinavirus$biden.fav, weights=black.postchinavirus$weight))

#look at latinx biden favorability over time; weights
prop.table(wtd.table(latinx.sect0$biden.fav, weights=latinx.sect0$weight))
prop.table(wtd.table(latinx.sect1$biden.fav, weights=latinx.sect1$weight))
prop.table(wtd.table(latinx.sect2$biden.fav, weights=latinx.sect2$weight))
prop.table(wtd.table(latinx.sect3$biden.fav, weights=latinx.sect3$weight))
prop.table(wtd.table(latinx.sect4$biden.fav, weights=latinx.sect4$weight))
prop.table(wtd.table(latinx.sect5$biden.fav, weights=latinx.sect5$weight))
prop.table(wtd.table(latinx.sect6$biden.fav, weights=latinx.sect6$weight))
prop.table(wtd.table(latinx.sect7$biden.fav, weights=latinx.sect7$weight))
prop.table(wtd.table(latinx.sect8$biden.fav, weights=latinx.sect8$weight))
prop.table(wtd.table(latinx.prechinavirus$biden.fav, weights=latinx.prechinavirus$weight))
prop.table(wtd.table(latinx.postchinavirus$biden.fav, weights=latinx.postchinavirus$weight))

###### #LOOOK AT ASIAN AMERICANS PARTY ID OVER TIME; WEIGHTS 
prop.table(wtd.table(aapi.sect0$party, weights=aapi.sect0$weight))
prop.table(wtd.table(aapi.sect1$party, weights=aapi.sect1$weight))
prop.table(wtd.table(aapi.sect2$party, weights=aapi.sect2$weight))
prop.table(wtd.table(aapi.sect3$party, weights=aapi.sect3$weight))
prop.table(wtd.table(aapi.sect4$party, weights=aapi.sect4$weight))
prop.table(wtd.table(aapi.sect5$party, weights=aapi.sect5$weight))
prop.table(wtd.table(aapi.sect6$party, weights=aapi.sect6$weight))
prop.table(wtd.table(aapi.sect7$party, weights=aapi.sect7$weight))
prop.table(wtd.table(aapi.sect8$party, weights=aapi.sect8$weight))
prop.table(wtd.table(aapi.prechinavirus$party, weights=aapi.prechinavirus$weight))
prop.table(wtd.table(aapi.postchinavirus$party, weight=aapi.postchinavirus$weight))

#look at white PARTY ID over time, weights
prop.table(wtd.table(white.sect0$party, weights=white.sect0$weight))
prop.table(wtd.table(white.sect1$party, weights=white.sect1$weight))
prop.table(wtd.table(white.sect2$party, weights=white.sect2$weight))
prop.table(wtd.table(white.sect3$party, weights=white.sect3$weight))
prop.table(wtd.table(white.sect4$party, weights=white.sect4$weight))
prop.table(wtd.table(white.sect5$party, weights=white.sect5$weight))
prop.table(wtd.table(white.sect6$party, weights=white.sect6$weight))
prop.table(wtd.table(white.sect7$party, weights=white.sect7$weight))
prop.table(wtd.table(white.sect8$party, weights=white.sect8$weight))
prop.table(wtd.table(white.prechinavirus$party, weights=white.prechinavirus$weight))
prop.table(wtd.table(white.postchinavirus$party, weights=white.postchinavirus$weight))

#look at black PARTY ID over time; weights
prop.table(wtd.table(black.sect0$party, weights=black.sect0$weight))
prop.table(wtd.table(black.sect1$party, weights=black.sect1$weight))
prop.table(wtd.table(black.sect2$party, weights=black.sect2$weight))
prop.table(wtd.table(black.sect3$party, weights=black.sect3$weight))
prop.table(wtd.table(black.sect4$party, weights=black.sect4$weight))
prop.table(wtd.table(black.sect5$party, weights=black.sect5$weight))
prop.table(wtd.table(black.sect6$party, weights=black.sect6$weight))
prop.table(wtd.table(black.sect7$party, weights=black.sect7$weight))
prop.table(wtd.table(black.sect8$party, weights=black.sect8$weight))
prop.table(wtd.table(black.prechinavirus$party, weights=black.prechinavirus$weight))
prop.table(wtd.table(black.postchinavirus$party, weights=black.postchinavirus$weight))

#look at latinx PARTY ID over time; weights
prop.table(wtd.table(latinx.sect0$party, weights=latinx.sect0$weight))
prop.table(wtd.table(latinx.sect1$party, weights=latinx.sect1$weight))
prop.table(wtd.table(latinx.sect2$party, weights=latinx.sect2$weight))
prop.table(wtd.table(latinx.sect3$party, weights=latinx.sect3$weight))
prop.table(wtd.table(latinx.sect4$party, weights=latinx.sect4$weight))
prop.table(wtd.table(latinx.sect5$party, weights=latinx.sect5$weight))
prop.table(wtd.table(latinx.sect6$party, weights=latinx.sect6$weight))
prop.table(wtd.table(latinx.sect7$party, weights=latinx.sect7$weight))
prop.table(wtd.table(latinx.sect8$party, weights=latinx.sect8$weight))
prop.table(wtd.table(latinx.prechinavirus$party, weights=latinx.prechinavirus$weight))
prop.table(wtd.table(latinx.postchinavirus$party, weights=latinx.postchinavirus$weight))


### READ IN CVS FILES FOR DATA POINTS TO CREATE FIGURE 4
demfav <- read_excel("C:/Users/natha/Downloads/demfav.xlsx")
bidenfav <- read_excel("C:/Users/natha/Downloads/bidenfav.xlsx")
dem <- read_excel("C:/Users/natha/Downloads/dempid.xlsx")

par(mfrow=c(2,2))
plot(x= demfav$num, y=demfav$value, col="white", xlab="Date", ylab="% Dem Favorability", axes=F)
lines(x= demfav$num[demfav$group=="White"], y=demfav$value[demfav$group=="White"], lty=2)
lines(x= demfav$num[demfav$group=="White"], y=demfav$value[demfav$group=="Latina/o"], lty=3)
lines(x= demfav$num[demfav$group=="White"], y=demfav$value[demfav$group=="Black"], lty=4)
lines(x= demfav$num[demfav$group=="White"], y=demfav$value[demfav$group=="Asian"], lty=1)
abline(v=7, lty=6, col="grey")
axis(side=1, at=c(5,6,7,8,9), labels=c("Jan '20","Feb '20","Mar '20", "Apr '20", "May '20"))
axis(side=2, las=2, at=seq(0.4,0.7,0.05), labels=paste0(seq(0.4,0.7,0.05)*100, "%"))

plot(x= bidenfav$num, y=bidenfav$value, col="white", xlab="Date", ylab="% Biden Favorability", axes=F)
lines(x= bidenfav$num[bidenfav$group=="White"], y=bidenfav$value[bidenfav$group=="White"], lty=2)
lines(x= bidenfav$num[bidenfav$group=="White"], y=bidenfav$value[bidenfav$group=="Latina/o"], lty=3)
lines(x= bidenfav$num[bidenfav$group=="White"], y=bidenfav$value[bidenfav$group=="Black"], lty=4)
lines(x= bidenfav$num[bidenfav$group=="White"], y=bidenfav$value[bidenfav$group=="Asian"], lty=1)
abline(v=7, lty=6, col="grey")
axis(side=1, at=c(5,6,7,8,9), labels=c("Jan '20","Feb '20","Mar '20", "Apr '20", "May '20"))
axis(side=2, las=2, at=seq(0.4,0.7,0.05), labels=paste0(seq(0.4,0.7,0.05)*100, "%"))

plot(x= dem$num, y=dem$value, col="white", xlab="Date", ylab="% Dem ID", axes=F)
lines(x= dem$num[dem$group=="White"], y=dem$value[dem$group=="White"], lty=2)
lines(x= dem$num[dem$group=="White"], y=dem$value[dem$group=="Latina/o"], lty=3)
lines(x= dem$num[dem$group=="White"], y=dem$value[dem$group=="Black"], lty=4)
lines(x= dem$num[dem$group=="White"], y=dem$value[dem$group=="Asian"], lty=1)
abline(v=7, lty=6, col="grey")
axis(side=1, at=c(5,6,7,8,9), labels=c("Jan '20","Feb '20","Mar '20", "Apr '20", "May '20"))
axis(side=2, las=2, at=seq(0.25,0.65,0.05), labels=paste0(seq(0.4,0.8,0.05)*100, "%"))

plot(x= dem$num, y=dem$value, col="white", xlab="", ylab="", axes=F)
legend("bottomleft", legend=c("White","Latina/o", "Black", "Asian"), lty=c(2,3,4,1),bty = "n")

### REGRESSION MODELS #### FIGURE 5

## AAPI DEM FAVORABILITY ####
mod1 <- lm(dem.fav.n~chinavirus+
             female+income+education.level+age+
             forborn+protestant+liberal+wave,data=aapi,weights=weight)
summary(mod1)

## AAPI BIDEN FAVORABILITY
mod2 <- lm(biden.fav.n~chinavirus+
             female+income+education.level+age+
             forborn+protestant+liberal+wave,data=aapi,weights=weight)
summary(mod2)

## AAPI DEM PARTY ##
mod3 <- glm(dem~chinavirus+
              female+income+education.level+age+
              forborn+protestant+liberal+wave,data=aapi, family="binomial",weights=weight)
summary(mod3)

#### AAPI INDEX
mod4 <- lm(prodem~chinavirus+
             female+income+education.level+age+
             forborn+protestant+liberal+wave,data=aapi,weights=weight)
summary(mod4)

#READ IN CSV FILE FOR POINTS USED TO CREATE FIGURE 5
asianamerican <- read_excel("nationscape_asianamerican_predictedprobabilities_2.xlsx")

#asian american
plota <-ggplot(asianamerican, aes(x=group, y=mean)) +
  geom_errorbar(aes(ymin=mean-ci, ymax=mean+ci), width=.1,position=position_dodge(width=0.4)) +
  geom_point() +
  geom_hline(yintercept=0, linetype="dashed", color = "grey") +
  labs(
    x ="", y = "Change in Predicted Probability")
plotafin <- plota+ coord_flip()
plotafin
ggsave("plotefin.png")


## FIGURE 6
#white: demfavorability 
mod5 <- lm(dem.fav.n~chinavirus+
             female+income+education.level+age+
             forborn+protestant+liberal+wave,data=white,weights=weight)
summary(mod5)

#biden:white
mod6 <- lm(biden.fav.n~chinavirus+
             female+income+education.level+age+
             forborn+protestant+liberal+wave,data=white, weights=weight)
summary(mod6)

#white dem party id
mod7 <- glm(dem~chinavirus+
              female+income+education.level+age+
              forborn+protestant+liberal+wave,data=white, family="binomial",weights=weight)
summary(mod7)

#white prodem
mod8 <- lm(prodem~chinavirus+
             female+income+education.level+age+
             forborn+protestant+liberal+wave,data=white, weights=weight)
summary(mod8)

#latinx dem fav
mod9 <- lm(dem.fav.n~chinavirus+
             female+income+education.level+age+
             forborn+protestant+liberal+wave,data=latinx, weights=weight)
summary(mod9)

#latinx biden
mod10 <- lm(biden.fav.n~chinavirus+
              female+income+education.level+age+
              forborn+protestant+liberal+wave,data=latinx, weights=weight)
summary(mod10)

#dem latinx
mod11 <- glm(dem~chinavirus+
               female+income+education.level+age+
               forborn+protestant+liberal+wave,data=latinx, family="binomial",weights=weight)
summary(mod11)

#index prodem latinx
mod12 <- lm(prodem~chinavirus+
              female+income+education.level+age+
              forborn+protestant+liberal+wave,data=latinx,weights=weight)
summary(mod12)

#AFAM DEM FAVORABILITY
mod13 <- lm(dem.fav.n~chinavirus+
              female+income+education.level+age+
              forborn+protestant+liberal+wave,data=black, weights=weight)
summary(mod13)

#biden for blacks
mod14 <- lm(biden.fav.n~chinavirus+
              female+income+education.level+age+
              forborn+protestant+liberal+wave,data=black, weights=weight)
summary(mod14)

#dem party affiliation; blacks
mod15 <- glm(dem~chinavirus+
               female+income+education.level+age+
               forborn+protestant+liberal+wave,data=black, family="binomial",weights=weight)
summary(mod15)

#prodem; blacks
mod16 <- lm(prodem~chinavirus+
              female+income+education.level+age+
              forborn+protestant+liberal+wave,data=black,weights=weight)
summary(mod16)

#READ IN CSV FILE THAT CREATES FIGURE 6
all <- read_excel("nationscape_allresults_predictedprobabilities_2.xlsx")

plotf <-ggplot(all, aes(x=group, y=mean, group=dv)) +
  geom_errorbar(aes(ymin=mean-ci, ymax=mean+ci), width=.1,position=position_dodge(width=0.4)) +
  geom_point(aes(shape=dv),size=2,
             position=position_dodge(width=0.4)) +
  geom_hline(yintercept=0, linetype="dashed", color = "grey") +
  labs(
    x ="Race", y = "Change in Predicted Probability", shape="Dependent Variables")
plotffin <- plotf+theme(legend.position="bottom")+guides(shape = guide_legend(nrow = 2, byrow=TRUE))
plotffin
ggsave("plotffin.png")


### TABLE 1 ANALYSES ###

#### ASIAN * RACE INTERACTIONS
table(scape$race)
table(scape$asian)
asian.black <- subset(scape,subset=(asian==1| race=="Black"))

asian.black$asian.int <- NA
asian.black$asian.int <- as.numeric(asian.black$asian.int)
asian.black$asian.int[asian.black$race_ethnicity==1] <- 0
asian.black$asian.int[asian.black$race_ethnicity==2] <- 0
asian.black$asian.int[asian.black$race_ethnicity==3] <- 0
asian.black$asian.int[asian.black$race_ethnicity==4] <- 1
asian.black$asian.int[asian.black$race_ethnicity==5] <- 1
asian.black$asian.int[asian.black$race_ethnicity==6] <- 1
asian.black$asian.int[asian.black$race_ethnicity==7] <- 1
asian.black$asian.int[asian.black$race_ethnicity==8] <- 1
asian.black$asian.int[asian.black$race_ethnicity==9] <- 1
asian.black$asian.int[asian.black$race_ethnicity==10] <- 1
asian.black$asian.int[asian.black$race_ethnicity==11] <- 1
asian.black$asian.int[asian.black$race_ethnicity==12] <- 1
asian.black$asian.int[asian.black$race_ethnicity==13] <- 1
asian.black$asian.int[asian.black$race_ethnicity==14] <- 1
asian.black$asian.int[asian.black$race_ethnicity==15] <- 0
table(asian.black$asian)

mod17 <- lm(prodem~chinavirus*asian.int+
              female+income+education.level+age+
              forborn+protestant+liberal+wave,data=asian.black,weights=weight)
summary(mod17)

#ASIAN.WHITE INTERACTION
asian.white <- subset(scape,subset=(race=="White"| asian==1))
asian.white$asian.int <- NA
asian.white$asian.int <- as.numeric(asian.white$asian.int)
asian.white$asian.int[asian.white$race_ethnicity==1] <- 0
asian.white$asian.int[asian.white$race_ethnicity==2] <- 0
asian.white$asian.int[asian.white$race_ethnicity==3] <- 0
asian.white$asian.int[asian.white$race_ethnicity==4] <- 1
asian.white$asian.int[asian.white$race_ethnicity==5] <- 1
asian.white$asian.int[asian.white$race_ethnicity==6] <- 1
asian.white$asian.int[asian.white$race_ethnicity==7] <- 1
asian.white$asian.int[asian.white$race_ethnicity==8] <- 1
asian.white$asian.int[asian.white$race_ethnicity==9] <- 1
asian.white$asian.int[asian.white$race_ethnicity==10] <- 1
asian.white$asian.int[asian.white$race_ethnicity==11] <- 1
asian.white$asian.int[asian.white$race_ethnicity==12] <- 1
asian.white$asian.int[asian.white$race_ethnicity==13] <- 1
asian.white$asian.int[asian.white$race_ethnicity==14] <- 1
asian.white$asian.int[asian.white$race_ethnicity==15] <- 0
table(asian.white$asian.int)

mod18 <- lm(prodem~chinavirus*asian.int+
              female+income+education.level+age+
              forborn+protestant+liberal+wave,data=asian.white,weights=weight)
summary(mod18)

#ASIAN. and LATINX INTERACTION
asian.latino <- subset(scape,subset=(latinx==1| asian==1))

asian.latino$asian.int <- NA
asian.latino$asian.int <- as.numeric(asian.latino$asian.int)
asian.latino$asian.int[asian.latino$race_ethnicity==1] <- 0
asian.latino$asian.int[asian.latino$race_ethnicity==2] <- 0
asian.latino$asian.int[asian.latino$race_ethnicity==3] <- 0
asian.latino$asian.int[asian.latino$race_ethnicity==4] <- 1
asian.latino$asian.int[asian.latino$race_ethnicity==5] <- 1
asian.latino$asian.int[asian.latino$race_ethnicity==6] <- 1
asian.latino$asian.int[asian.latino$race_ethnicity==7] <- 1
asian.latino$asian.int[asian.latino$race_ethnicity==8] <- 1
asian.latino$asian.int[asian.latino$race_ethnicity==9] <- 1
asian.latino$asian.int[asian.latino$race_ethnicity==10] <- 1
asian.latino$asian.int[asian.latino$race_ethnicity==11] <- 1
asian.latino$asian.int[asian.latino$race_ethnicity==12] <- 1
asian.latino$asian.int[asian.latino$race_ethnicity==13] <- 1
asian.latino$asian.int[asian.latino$race_ethnicity==14] <- 1
asian.latino$asian.int[asian.latino$race_ethnicity==15] <- 0
table(asian.latino$asian.int)

mod19 <- lm(prodem~chinavirus*asian.int+
              female+income+education.level+age+
              forborn+protestant+liberal+wave,data=asian.latino,weights=weight)
summary(mod19)

## APPENDIX: TABLE B8
mod20 <- lm(prodem~chinavirus*income.bin+
              female+income+education.level+age+
              forborn+protestant+liberal+wave,data=aapi,weights=weight)
summary(mod20)

### APPENDIX: TABLE B6
mod21 <- lm(prodem~chinavirus+
              female+income+education.level+age+
              forborn+protestant+liberal+wave,data=aapi.trunc,weights=weight)
summary(mod21)
